/****** Object:  StoredProcedure [dbo].[sp_AddNewCustomer]    Script Date: 05/06/2011 23:57:58 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_AddNewCustomer]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_AddNewCustomer]
GO

/****** Object:  StoredProcedure [dbo].[sp_AddNewCustomer]    Script Date: 05/06/2011 23:57:58 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Bui Thanh Nam
-- Create date: 06-05-2011
-- Description:	Add new customer
-- =============================================
CREATE PROCEDURE [dbo].[sp_AddNewCustomer]

	@CustomerName			NVARCHAR(100),
	@ContractNo				NVARCHAR(50),
	@StartDate				DATE,
    @EndDate				DATE,
    @Address				NVARCHAR(300),
	@Telephone				NVARCHAR(20),
	@Mobile					NVARCHAR(20),	
	@Email					NVARCHAR(50),	
	@TaxCode				NVARCHAR(50),
	@BankAccount			NVARCHAR(50),
	@BankName				NVARCHAR(100),
	@PresentativeName		NVARCHAR(100),
	@PresentativeJobTitle	NVARCHAR(50),
	@InsuranceType			NVARCHAR(50),
	@InsuranceTarget		NVARCHAR(50)

AS
BEGIN
	
	SET NOCOUNT ON;
	
	INSERT INTO [Customer] (
								[CustomerName], [ContractNo], [StartDate], [EndDate],
								[Address], [Telephone], [Mobile], [Email], [TaxCode],
								[BankAccount], [BankName], [PresentativeName], [PresentativeJobTitle],
								[InsuranceType], [InsuranceTarget]
							)
    VALUES					(
								@CustomerName, @ContractNo, CONVERT(DATE,@StartDate), CONVERT(DATE,@EndDate),
								@Address, @Telephone, @Mobile , @Email,	@TaxCode,
								@BankAccount, @BankName, @PresentativeName, @PresentativeJobTitle,
								@InsuranceType, @InsuranceTarget
							)
   
END

GO


